<?php
class api {
    private $status;
    private $return;
    private $desc;
    
    public function __construct() {
        $this->status = array("status"=>"","details"=>"");
        $this->setFail();
        $this->return = array();
    }
    
    public function setFail($details="") {
        $this->setStatus("fail");
        $this->setDetails($details);
    }

    public function setOK($details="") {
        $this->setStatus("ok");
        $this->setDetails($details);
    }
    
    public function setYouFail($details="") {
        $this->setStatus("youfail");
        $this->setDetails($details);
    }
    
    private function setDetails($details) {
        $this->status["details"] = $details;
    }
    
    private function setStatus($status) {
        $this->status["status"] = $status;
    }

    public function setReturn($key,$return) {
        $this->return[$key] = $return;
    }

    public function returnResponse() {
        echo json_encode(array_merge($this->status,$this->return));
        //header("Location:" . $_SERVER["HTTP_REFERER"]);
    }
}
?>